/**
 * @file   captura.h
 * @author Pedro
 * @date   Thu Nov  6 12:24:35 2008
 * 
 * @brief  Estructuras de datos y cabeceras de funciones necesarias para la captura de video mediante Firewire.
 * 
 * 
 */
#ifndef _CAPTURA_H_
#define _CAPTURA_H_

//#include <gtk/gtk.h>

#include "dc_captura.h"
#include "serial.h"
#include "queue"


#define TIME_SLEEP_COMPRESOR_USEC 250000 //250 ms

typedef struct {
    IplImage * img;
    //frame_header head;
} image_params_t;

typedef struct {
    camera_control * camera;
    int cam;
    pthread_mutex_t mutex_img;
    pthread_mutex_t mutex_free;
    std::queue <image_params_t *> queue_img;
    std::queue <image_params_t *> queue_free_img;
    char filename[300];
    pthread_t thread;
    int fourcc;
    bool quit;
    bool cerrar_video;
    CvVideoWriter * video;
    FILE *file;
    int buffer_img_size;
    struct timeval lastfilltime;
    int readframes;
} captura_params_t;

void* pthread_func_f_capture (void*);
int f_capture_init (camera_control* cameras, CvRect roi, int argc, char **argv);
void* pthread_func_f_simulate (void *);
void * pthread_func_f_show_capture (void* params);
//bool grabar_frame(camera_control * cameras, FILE ** pfile_write_video);
bool grabar_frame(captura_params_t * captura);
void * pthread_func_compression_thread(void * params);
void * pthread_func_storing_thread(void * params);
void init_captura_and_save(captura_params_t * captura, int buffers);
void onmouse (int event, int x, int y, int flags, void* param);
void finish_captura_and_save(captura_params_t * captura);
void finalizar_grabacion(captura_params_t * captura);
void iniciar_grabacion(captura_params_t * captura, const char *filename);
void finalizar_compresion(captura_params_t * captura);
void iniciar_compresion(captura_params_t * captura, const char *filename);
void * pthread_func_print_capture_info(void * parametro);


#ifdef _CAPTURA_CPP_

#else


#endif

#endif
